﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Acms.Exceptions;

namespace Registration
{
    /// <summary>
    /// Summary description for WorldClassSignup
    /// </summary>
    public partial class WorldClassSignup
    {
        partial void OnValidate(System.Data.Linq.ChangeAction action)
        {
            if (action == System.Data.Linq.ChangeAction.Insert)
            {
                Created = DateTime.Now;
            }

            if (Name != null)
            {
                if (Name.Trim() == "")
                {
                    Name = null;
                }
            }

            if (EmailAddress != null)
            {
                if (EmailAddress.Trim() == "")
                {
                    EmailAddress = null;
                }
            }

            if (Job != null)
            {
                if (Job.Trim() == "")
                {
                    Job = null;
                }
            }

            if (Bar != null)
            {
                if (Bar.Trim() == "")
                {
                    Bar = null;
                }
            }

            if (City != null)
            {
                if (City.Trim() == "")
                {
                    City = null;
                }
            }

            if (Country != null)
            {
                if (Country.Trim() == "")
                {
                    Country = null;
                }
            }

            if (MainCountry != null)
            {
                if (MainCountry.Trim() == "")
                {
                    MainCountry = null;
                }
            }
            
            ValidationException exceptions = new ValidationException();
            if (string.IsNullOrEmpty(Name))
            {
                exceptions.Add("Name must be entered");
            }
            if (string.IsNullOrEmpty(EmailAddress))
            {
                exceptions.Add("Email Address must be entered");
            }
            else
            {
            }

            if (exceptions.Items.Length > 0)
            {
                throw exceptions;
            }

        }
    }
}
